//
//  CartCell.m
//  WuJieLive
//
//  Created by iMac on 2017/12/4.
//  Copyright © 2017年 zhk. All rights reserved.
//

#import "CartCell.h"

@implementation CartCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupView];
}

- (void)setupView
{
    self.counterView = [[[NSBundle mainBundle] loadNibNamed:@"CounterView" owner:self options:nil] lastObject];
    [self.contentView addSubview:self.counterView];
    [self.counterView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-15);
        make.width.offset(90);
        make.bottom.equalTo(self.nowPriceLabel.mas_bottom);
        make.height.offset(30);
    }];
}

-(void)bindDataWithModel:(CartModel *)model
{
    [self.goodsImage sd_setImageWithURL:[NSURL URLWithString:model.goods_picture] placeholderImage:PlaceImage];
    self.goodsNameLabel.text = model.goods_name;
    self.specificationLabel.text = model.goods_spec_name;
    self.nowPriceLabel.text = model.price_coupon;
    self.oldPirceLabel.text = model.price;
    if ([model.goods_status integerValue] == 2) {
        self.blackBtn.hidden = NO;
        self.counterView.hidden = YES;
    }
    self.selectBtn.selected = model.isSelected;
    self.counterView.numText.text = model.goods_number;
}
- (IBAction)selectAction:(UIButton *)sender {
    sender.selected = !sender.isSelected;
    if (self.selectedBlock) {
        self.selectedBlock(sender.selected);
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
